public class LoginCommand {
    public static void loginCommand(Person person) {
        boolean over = false;
        String op;// 储存单行

        while (!over) {
            op = MyUtil.in.nextLine();
            String[] command = op.split("\\s+");// 将一行字符串分割为指令+多个参数
            switch (command[0]) {
            case "chgpw":
                if (MyUtil.checkMainCommand(command, 0)) {
                    person.changePWD(command[1], command[2]);
                }
                break;
            case "myinfo":
                if (MyUtil.checkMainCommand(command, 0)) {
                    person.thisInfo();
                }
                break;
            case "back":
                if (MyUtil.checkMainCommand(command, 0)) {
                    System.out.println(MyUtil.LOGIN_LOGOUT);
                    over = true;
                }
                break;
            case "QUIT":
                if (MyUtil.checkMainCommand(command, 0)) {
                    System.out.println(MyUtil.BYE);
                    System.exit(0);
                }
                break;
            case "rc":
                if (MyUtil.checkLoginCommand(person, command, 0)) {
                    ((Customer) person).recharge(command[1]);
                }
                break;
            case "gb":
                if (MyUtil.checkLoginCommand(person, command, 0)) {
                    System.out.println("Balance: " + ((Customer) person).getBalance());
                }
                break;
            case "aplVIP":
                if (MyUtil.checkLoginCommand(person, command, 0)) {
                    ((Customer) person).toVip();
                }
                break;
            default:
                System.out.println(MyUtil.NO_COMMAND);
                break;
            }
        }
    }
}
